﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BO.Admin;
using BO;

namespace ProjectQuaDep.Admin.News
{
    public partial class ManagerCategory : System.Web.UI.Page
    {
        string sFormat = "<li><fieldset><legend>{0}</legend>{1}</fieldset></li>";
        string sItem = "+ {0}</br>";
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            dt = NewsBO.getAllZoneCache();
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string linkEdit = "<a href=\"/Admin/News/EditZone.aspx?type=edit&lv=1&id=" + dt.Rows[i][Const.tbZoneNews.ZoneId].ToString() + "\">" + dt.Rows[i][Const.tbZoneNews.title].ToString() + "</a>";
                    string ParentId = dt.Rows[i][Const.tbZoneNews.ZoneId].ToString();
                    DataTable dtZoneSub = new DataTable();
                    dtZoneSub = NewsBO.getAllZoneByParentIdCache(ParentId);
                    string kq = "";
                    if (dtZoneSub.Rows.Count > 0)
                    {
                        for (int j = 0; j < dtZoneSub.Rows.Count; j++)
                        {
                            string linkEditSub = "<a href=\"/Admin/News/EditZone.aspx?type=edit&lv=2&parentId=" + ParentId + "&id=" + dtZoneSub.Rows[j][Const.tbZoneNews.ZoneId].ToString() + "\">" + dtZoneSub.Rows[j][Const.tbZoneNews.title].ToString() + "</a>";
                            kq += string.Format(sItem, linkEditSub);
                        }
                    }
                    ltloadMenuLv1.Text += string.Format(sFormat, linkEdit, kq);
                }
            }
        }

        protected void ibAddLv1_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("/Admin/News/EditZone.aspx?type=add&lv=1");
        }

        protected void ibAddlv2_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("/Admin/News/EditZone.aspx?type=add&lv=2");
        }
    }
}